<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .nav{
            width: 800px;
            margin: 200px auto;
            display: flex;
            justify-content: space-around;
            font-size: 21px;
            font-weight: bold;
        }
        .nav li{
            list-style: none;
            text-align: center;
        }
        a{
            text-decoration: none;
        }
        .nav ul{
            text-align: center;
            display: none;
        }
    </style>
</head>
<body>
    <ul class="nav">
        <li>
            <a href="">微博</a>
            <ul>
                <li><a href="">私信</a></li>
                <li><a href="">评论</a></li>
            </ul>
        </li>
        <li>
            <a href="">QQ</a>
            <ul>
                <li><a href="">私信</a></li>
                <li><a href="">评论</a></li>
            </ul>
        </li>
        <li>
            <a href="">支付宝</a>
            <ul>
                <li><a href="">私信</a></li>
                <li><a href="">评论</a></li>
            </ul>
        </li>
        <li>
            <a href="">微信</a>
            <ul>
                <li><a href="">私信</a></li>
                <li><a href="">评论</a></li>
            </ul>
        </li>
    </ul>
    <script>
        var nav = document.querySelector('.nav')
        var lis = nav.children
        for(var i = 0;i<lis.length;i++){
            lis[i].onmouseover = function(){
                this.children[1].style.display = 'block'
                this.children[0].style.background = 'lightgray'
            }
            lis[i].onmouseout = function(){
                this.children[1].style.display = 'none'
                this.children[0].style.background = 'none'

            }
        }
    </script>
</body>
</html>